package com.he1618.boot3.app;

import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.analysis.solvers.*;

public class EquationSolvingExample {

    public static void main(String[] args) {
        // 创建方程
        UnivariateFunction equation = x -> Math.pow(x, 2) - 4;

        // 创建求解器
        UnivariateSolver solver = new BrentSolver();

        // 解方程
        double solution = solver.solve(100, equation, 0, 3);

        // 输出结果
        System.out.println("Solution: " + solution);
    }
}
